<?php

/**
 * Description of emailer
 *
 * @author Kishore
 */
class emailer {
    var $recipients = array();
    var $emailTemplate;
    var $emailContents;
    
    public function __construct($to = false) {
        if ($to !== false) {
            if (is_array($to)) {
                foreach ($to as $_to) {
                    $this->recipients[$to] = $_to;
                } 
            } else {
                $this->recipients[$to] = $to;
            } // is_array
        } //$to !== false
    }
    
    function setTemplate(EmailTemplate $emailTemplate) {
        $this->emailTemplate = $emailTemplate;

    }
    
    function sendEmail() {
        
    }
}

class EmailTemplate {
    var $variables = array();
    var $templateFile = array();
    
    function __construct($templateFile) {
        if (!file_exists($templateFile)) {
            trigger_error($templateFile . ' not found.', E_USER_ERROR);
            return;
        }
        
        $this->templateFile = $templateFile;
    }
    
    public function __set($key, $val) {
        // populate $variables array
        $this->variables[$key] = $val;
    }
    
    public function compile() {
        ob_start();
        
        extract($this->variables);
    }
}
?>
